package al560subStringSumK;

import java.util.HashSet;

public class AddEqualK {

    public static int subarraySum(int[] nums, int k) {
        int geshu = 0;
        int sum = 0;
        int left;
        int right;
        for( left=0;left<nums.length;left++){
            sum = nums[left];
            if(sum == k)
                geshu++;
            for(right=left+1;right<nums.length;right++){
                sum = sum + nums[right];
                if(sum == k){
                    geshu++;
                }
            }
        }
        return geshu;
    }



    public static void main(String[] args) {

        int[] sum ={28,54,7,-70,22,65,-6};
        int i = subarraySum(sum, 100);
        System.out.println(i);
    }
}
